package com.ct.lotterysystem2.common.exception;

import com.ct.lotterysystem2.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;


@Data
@EqualsAndHashCode(callSuper = true)
public class ControllerException extends RuntimeException {

    /**
     * 异常码
     * @see com.ct.lotterysystem2.common.errorcode.ControllerErrorCodeConstants;
     */
    private Integer code;

    /**
     * 异常信息
     */
    private String message;


    /**
     * 无参构造函数为了序列化
     */
    public ControllerException() {

    }

    // 手动指定的异常
    public ControllerException (Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    // 通过 ErrorCode接口创建异常
    public ControllerException (ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }
}
